﻿using Little.Soldier.SWIFT;
using Little.Soldier.SWIFT.Definition;
using System.Collections.Generic;
using System.ComponentModel;

namespace Little.Soldier.SWIFT.Messages.Category8
{
  public class MT801 : SwiftMessage
  {
    private static SwiftMessageDefinition MessageDefinition;
    private static SwiftTagDefinition U0002;
    private static SwiftTagSubItemDefinition U0003;
    private static SwiftTagDefinition U0004;
    private static SwiftTagSubItemDefinition U0005;
    private static SwiftTagSubItemDefinition U0006;
    private static SwiftTagSubItemDefinition U0007;
    private static SwiftTagSequenceDefinition U0008;
    private static SwiftTagChoiceDefinition U000E;
    private static SwiftTagDefinition U000F;
    private static SwiftTagSubItemDefinition U0010;
    private static SwiftTagSubItemDefinition U0011;
    private static SwiftTagDefinition U0012;
    private static SwiftTagSubItemDefinition U0013;
    private static SwiftTagSequenceDefinition U0014;
    private static SwiftTagDefinition U0015;
    private static SwiftTagSubItemDefinition U0016;
    private static SwiftTagDefinition U0017;
    private static SwiftTagSubItemDefinition U0018;
    private static SwiftTagDefinition U0019;
    private static SwiftTagSubItemDefinition U001A;
    private static SwiftTagSubItemDefinition U001B;
    private static SwiftTagSubItemDefinition U001C;
    private static SwiftTagDefinition U001D;
    private static SwiftTagSubItemDefinition U001E;
    private static SwiftTagSubItemDefinition U001F;
    private static SwiftTagDefinition U007F;
    private static SwiftTagDefinition U0080;
    private static SwiftTagSubItemDefinition U0081;
    private static SwiftTagSubItemDefinition U0082;
    private static SwiftTagDefinition U0083;
    private static SwiftTagSubItemDefinition U0084;

    [Description("Transaction Reference Number")]
    public Tag20 TransactionReferenceNumber_20
    {
      get
      {
        return new Tag20((SwiftElement) this, 0, (SwiftDefinitionElement) MT801.U0002);
      }
    }

    [Description("Transaction Reference Number")]
    public Tag20 Tag20_TransactionReferenceNumber
    {
      get
      {
        return this.TransactionReferenceNumber_20;
      }
    }

    [Description("Settlement Number/Page Number")]
    public Tag28 SettlementNumberPageNumber_28
    {
      get
      {
        return new Tag28((SwiftElement) this, 0, (SwiftDefinitionElement) MT801.U0004);
      }
    }

    [Description("Settlement Number/Page Number")]
    public Tag28 Tag28_SettlementNumberPageNumber
    {
      get
      {
        return this.SettlementNumberPageNumber_28;
      }
    }

    [Description("Selling Agent and Purchase Details")]
    public MT801.SellingAgentAndPurchaseDetails_SequenceClass[] SellingAgentAndPurchaseDetails_Sequence
    {
      get
      {
        int index = -1;
        List<MT801.SellingAgentAndPurchaseDetails_SequenceClass> list = new List<MT801.SellingAgentAndPurchaseDetails_SequenceClass>();
        int count;
        do
        {
          ++index;
          MT801.SellingAgentAndPurchaseDetails_SequenceClass detailsSequenceClass = new MT801.SellingAgentAndPurchaseDetails_SequenceClass((SwiftElement) this, index, false);
          count = this.ListTags((SwiftElement) detailsSequenceClass).Count;
          if (count > 0)
            list.Add(detailsSequenceClass);
        }
        while (count > 0);
        return list.ToArray();
      }
    }

    public MT801()
      : base(true)
    {
    }

    public MT801(SwiftMessage message)
      : base(message)
    {
    }

    public MT801.SellingAgentAndPurchaseDetails_SequenceClass AddSellingAgentAndPurchaseDetails_Sequence()
    {
      return new MT801.SellingAgentAndPurchaseDetails_SequenceClass((SwiftElement) this, this.SellingAgentAndPurchaseDetails_Sequence.Length, true);
    }

    public void RemoveSellingAgentAndPurchaseDetails_Sequence(MT801.SellingAgentAndPurchaseDetails_SequenceClass sequence)
    {
      foreach (SwiftTag tag in this.ListTags((SwiftElement) sequence))
        this.RemoveTag(tag);
    }

    internal override SwiftMessageDefinition MsgDefinition()
    {
      return MT801.MessageDefinition;
    }

    protected override void InitSwiftMessageDefinition()
    {
      MT801.MessageDefinition = new SwiftMessageDefinition("MT801", "Multiple Sales Advice");
      MT801.U0002 = new SwiftTagDefinition("TransactionReferenceNumber_20", "Transaction Reference Number");
      MT801.U0002.TagName = ":20:";
      MT801.U0003 = new SwiftTagSubItemDefinition("Reference", "Transaction Reference Number");
      MT801.U0002.Elements.Add((SwiftDefinitionElement) MT801.U0003);
      MT801.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT801.U0002);
      MT801.U0004 = new SwiftTagDefinition("SettlementNumberPageNumber_28", "Settlement Number/Page Number");
      MT801.U0004.TagName = ":28:";
      MT801.U0005 = new SwiftTagSubItemDefinition("SettlementNumber", "SettlementNumber");
      MT801.U0004.Elements.Add((SwiftDefinitionElement) MT801.U0005);
      MT801.U0006 = new SwiftTagSubItemDefinition("PageNumber", "Page Number");
      MT801.U0006.Mandatory = false;
      MT801.U0007 = new SwiftTagSubItemDefinition("PageNumber_1", "Page Number");
      MT801.U0006.Elements.Add((SwiftDefinitionElement) MT801.U0007);
      MT801.U0004.Elements.Add((SwiftDefinitionElement) MT801.U0006);
      MT801.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT801.U0004);
      MT801.U0008 = new SwiftTagSequenceDefinition("SellingAgentAndPurchaseDetails_Sequence", "Selling Agent and Purchase Details");
      MT801.U0008.Multiple = true;
      MT801.U000E = new SwiftTagChoiceDefinition("Choice", "");
      MT801.U000E.Multiple = true;
      MT801.U000F = new SwiftTagDefinition("SellingAgent_51A", "Selling Agent");
      MT801.U000F.TagName = ":51A:";
      MT801.U000F.Multiple = true;
      MT801.U0010 = new SwiftTagSubItemDefinition("PartyIdentifier", "Party Identifier");
      MT801.U0010.Mandatory = false;
      MT801.U000F.Elements.Add((SwiftDefinitionElement) MT801.U0010);
      MT801.U0011 = new SwiftTagSubItemDefinition("BankIdentifierCode", "Bank Identifier Code");
      MT801.U000F.Elements.Add((SwiftDefinitionElement) MT801.U0011);
      MT801.U000E.Elements.Add((SwiftDefinitionElement) MT801.U000F);
      MT801.U0012 = new SwiftTagDefinition("SellingAgent_51C", "Selling Agent");
      MT801.U0012.TagName = ":51C:/";
      MT801.U0012.Multiple = true;
      MT801.U0013 = new SwiftTagSubItemDefinition("Account", "Account");
      MT801.U0012.Elements.Add((SwiftDefinitionElement) MT801.U0013);
      MT801.U000E.Elements.Add((SwiftDefinitionElement) MT801.U0012);
      MT801.U0008.Elements.Add((SwiftDefinitionElement) MT801.U000E);
      MT801.U0014 = new SwiftTagSequenceDefinition("PurchaseDetails_Sequence", "Purchase Details");
      MT801.U0014.Multiple = true;
      MT801.U0015 = new SwiftTagDefinition("PurchaseAgreementID_23", "Purchase Agreement ID");
      MT801.U0015.TagName = ":23:";
      MT801.U0016 = new SwiftTagSubItemDefinition("PurchaseAgreementID", "Purchase Agreement ID");
      MT801.U0015.Elements.Add((SwiftDefinitionElement) MT801.U0016);
      MT801.U0014.Elements.Add((SwiftDefinitionElement) MT801.U0015);
      MT801.U0017 = new SwiftTagDefinition("SalesDate_30", "Sales Date");
      MT801.U0017.TagName = ":30:";
      MT801.U0017.Mandatory = false;
      MT801.U0018 = new SwiftTagSubItemDefinition("Date", "Date");
      MT801.U0017.Elements.Add((SwiftDefinitionElement) MT801.U0018);
      MT801.U0014.Elements.Add((SwiftDefinitionElement) MT801.U0017);
      MT801.U0019 = new SwiftTagDefinition("SerialNumbers_26A", "Serial Numbers");
      MT801.U0019.TagName = ":26A:";
      MT801.U0019.Multiple = true;
      MT801.U001A = new SwiftTagSubItemDefinition("Number1", "Number1");
      MT801.U0019.Elements.Add((SwiftDefinitionElement) MT801.U001A);
      MT801.U001B = new SwiftTagSubItemDefinition("Number2", "Number2");
      MT801.U001B.Mandatory = false;
      MT801.U001C = new SwiftTagSubItemDefinition("Number2_1", "Number2");
      MT801.U001B.Elements.Add((SwiftDefinitionElement) MT801.U001C);
      MT801.U0019.Elements.Add((SwiftDefinitionElement) MT801.U001B);
      MT801.U0014.Elements.Add((SwiftDefinitionElement) MT801.U0019);
      MT801.U001D = new SwiftTagDefinition("FaceAmount_33B", "Face Amounts");
      MT801.U001D.TagName = ":33B:";
      MT801.U001E = new SwiftTagSubItemDefinition("Currency", "Currency");
      MT801.U001D.Elements.Add((SwiftDefinitionElement) MT801.U001E);
      MT801.U001F = new SwiftTagSubItemDefinition("Amount", "Amount");
      MT801.U001D.Elements.Add((SwiftDefinitionElement) MT801.U001F);
      MT801.U0014.Elements.Add((SwiftDefinitionElement) MT801.U001D);
      MT801.U007F = new SwiftTagDefinition("AdditionalAmounts_73", "Additional Amounts");
      MT801.U007F.TagName = ":73:";
      MT801.U007F.Mandatory = false;
      MT801.U0014.Elements.Add((SwiftDefinitionElement) MT801.U007F);
      MT801.U0008.Elements.Add((SwiftDefinitionElement) MT801.U0014);
      MT801.U0080 = new SwiftTagDefinition("SellingAgentAmount_34B", "Selling Amount Agent");
      MT801.U0080.TagName = ":34B:";
      MT801.U0081 = new SwiftTagSubItemDefinition("Currency", "Currency");
      MT801.U0080.Elements.Add((SwiftDefinitionElement) MT801.U0081);
      MT801.U0082 = new SwiftTagSubItemDefinition("Amount", "Amount");
      MT801.U0080.Elements.Add((SwiftDefinitionElement) MT801.U0082);
      MT801.U0008.Elements.Add((SwiftDefinitionElement) MT801.U0080);
      MT801.U0083 = new SwiftTagDefinition("SellingsAgentNumberOfPAs_16A", "Sellings Agent Number Of PAs");
      MT801.U0083.TagName = ":16A:";
      MT801.U0084 = new SwiftTagSubItemDefinition("Number", "Number");
      MT801.U0083.Elements.Add((SwiftDefinitionElement) MT801.U0084);
      MT801.U0008.Elements.Add((SwiftDefinitionElement) MT801.U0083);
      MT801.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT801.U0008);
    }

    public class SellingAgentAndPurchaseDetails_SequenceClass : SwiftTagSequence
    {
      internal override SwiftDefinitionElement Definition
      {
        get
        {
          return (SwiftDefinitionElement) MT801.U0008;
        }
      }

      [Description("Selling Agent")]
      public Tag51A[] SellingAgent_51A
      {
        get
        {
          int index = -1;
          List<Tag51A> list = new List<Tag51A>();
          int count;
          do
          {
            ++index;
            Tag51A tag51A = new Tag51A((SwiftElement) this, index, (SwiftDefinitionElement) MT801.U000F);
            count = this.ListTags((SwiftElement) tag51A).Count;
            if (count > 0)
              list.Add(tag51A);
          }
          while (count > 0);
          return list.ToArray();
        }
      }

      [Description("Selling Agent")]
      public Tag51A[] Tag51A_SellingAgent
      {
        get
        {
          return this.SellingAgent_51A;
        }
      }

      [Description("Selling Agent")]
      public Tag51C[] SellingAgent_51C
      {
        get
        {
          int index = -1;
          List<Tag51C> list = new List<Tag51C>();
          int count;
          do
          {
            ++index;
            Tag51C tag51C = new Tag51C((SwiftElement) this, index, (SwiftDefinitionElement) MT801.U0012);
            count = this.ListTags((SwiftElement) tag51C).Count;
            if (count > 0)
              list.Add(tag51C);
          }
          while (count > 0);
          return list.ToArray();
        }
      }

      [Description("Selling Agent")]
      public Tag51C[] Tag51C_SellingAgent
      {
        get
        {
          return this.SellingAgent_51C;
        }
      }

      [Description("Purchase Details")]
      public MT801.SellingAgentAndPurchaseDetails_SequenceClass.PurchaseDetails_SequenceClass[] PurchaseDetails_Sequence
      {
        get
        {
          int index = -1;
          List<MT801.SellingAgentAndPurchaseDetails_SequenceClass.PurchaseDetails_SequenceClass> list = new List<MT801.SellingAgentAndPurchaseDetails_SequenceClass.PurchaseDetails_SequenceClass>();
          int count;
          do
          {
            ++index;
            MT801.SellingAgentAndPurchaseDetails_SequenceClass.PurchaseDetails_SequenceClass detailsSequenceClass = new MT801.SellingAgentAndPurchaseDetails_SequenceClass.PurchaseDetails_SequenceClass((SwiftElement) this, index, false);
            count = this.ListTags((SwiftElement) detailsSequenceClass).Count;
            if (count > 0)
              list.Add(detailsSequenceClass);
          }
          while (count > 0);
          return list.ToArray();
        }
      }

      [Description("Selling Amount Agent")]
      public Tag34B SellingAgentAmount_34B
      {
        get
        {
          return new Tag34B((SwiftElement) this, 0, (SwiftDefinitionElement) MT801.U0080);
        }
      }

      [Description("Selling Amount Agent")]
      public Tag34B Tag34B_SellingAgentAmount
      {
        get
        {
          return this.SellingAgentAmount_34B;
        }
      }

      [Description("Sellings Agent Number Of PAs")]
      public Tag16A SellingsAgentNumberOfPAs_16A
      {
        get
        {
          return new Tag16A((SwiftElement) this, 0, (SwiftDefinitionElement) MT801.U0083);
        }
      }

      [Description("Sellings Agent Number Of PAs")]
      public Tag16A Tag16A_SellingsAgentNumberOfPAs
      {
        get
        {
          return this.SellingsAgentNumberOfPAs_16A;
        }
      }

      internal SellingAgentAndPurchaseDetails_SequenceClass(SwiftElement parent, int index, bool createTags)
        : base(parent, index, createTags)
      {
      }

      public Tag51A AddSellingAgent_51A()
      {
        return new Tag51A((SwiftElement) this, this.SellingAgent_51A.Length, (SwiftDefinitionElement) MT801.U000F)
        {
          Value = string.Empty
        };
      }

      public void RemoveSellingAgent_51A(Tag51A tag)
      {
        this.RemoveTag(tag.GetTag());
      }

      public Tag51C AddSellingAgent_51C()
      {
        return new Tag51C((SwiftElement) this, this.SellingAgent_51C.Length, (SwiftDefinitionElement) MT801.U0012)
        {
          Value = string.Empty
        };
      }

      public void RemoveSellingAgent_51C(Tag51C tag)
      {
        this.RemoveTag(tag.GetTag());
      }

      public MT801.SellingAgentAndPurchaseDetails_SequenceClass.PurchaseDetails_SequenceClass AddPurchaseDetails_Sequence()
      {
        return new MT801.SellingAgentAndPurchaseDetails_SequenceClass.PurchaseDetails_SequenceClass((SwiftElement) this, this.PurchaseDetails_Sequence.Length, true);
      }

      public void RemovePurchaseDetails_Sequence(MT801.SellingAgentAndPurchaseDetails_SequenceClass.PurchaseDetails_SequenceClass sequence)
      {
        foreach (SwiftTag tag in this.ListTags((SwiftElement) sequence))
          this.RemoveTag(tag);
      }

      public class PurchaseDetails_SequenceClass : SwiftTagSequence
      {
        internal override SwiftDefinitionElement Definition
        {
          get
          {
            return (SwiftDefinitionElement) MT801.U0014;
          }
        }

        [Description("Purchase Agreement ID")]
        public Tag23 PurchaseAgreementID_23
        {
          get
          {
            return new Tag23((SwiftElement) this, 0, (SwiftDefinitionElement) MT801.U0015);
          }
        }

        [Description("Purchase Agreement ID")]
        public Tag23 Tag23_PurchaseAgreementID
        {
          get
          {
            return this.PurchaseAgreementID_23;
          }
        }

        [Description("Sales Date")]
        public Tag30 SalesDate_30
        {
          get
          {
            return new Tag30((SwiftElement) this, 0, (SwiftDefinitionElement) MT801.U0017);
          }
        }

        [Description("Sales Date")]
        public Tag30 Tag30_SalesDate
        {
          get
          {
            return this.SalesDate_30;
          }
        }

        [Description("Serial Numbers")]
        public Tag26A[] SerialNumbers_26A
        {
          get
          {
            int index = -1;
            List<Tag26A> list = new List<Tag26A>();
            int count;
            do
            {
              ++index;
              Tag26A tag26A = new Tag26A((SwiftElement) this, index, (SwiftDefinitionElement) MT801.U0019);
              count = this.ListTags((SwiftElement) tag26A).Count;
              if (count > 0)
                list.Add(tag26A);
            }
            while (count > 0);
            return list.ToArray();
          }
        }

        [Description("Serial Numbers")]
        public Tag26A[] Tag26A_SerialNumbers
        {
          get
          {
            return this.SerialNumbers_26A;
          }
        }

        [Description("Face Amounts")]
        public Tag33B FaceAmount_33B
        {
          get
          {
            return new Tag33B((SwiftElement) this, 0, (SwiftDefinitionElement) MT801.U001D);
          }
        }

        [Description("Face Amounts")]
        public Tag33B Tag33B_FaceAmount
        {
          get
          {
            return this.FaceAmount_33B;
          }
        }

        [Description("Additional Amounts")]
        public Tag73 AdditionalAmounts_73
        {
          get
          {
            return new Tag73((SwiftElement) this, 0, (SwiftDefinitionElement) MT801.U007F);
          }
        }

        [Description("Additional Amounts")]
        public Tag73 Tag73_AdditionalAmounts
        {
          get
          {
            return this.AdditionalAmounts_73;
          }
        }

        internal PurchaseDetails_SequenceClass(SwiftElement parent, int index, bool createTags)
          : base(parent, index, createTags)
        {
        }

        public Tag26A AddSerialNumbers_26A()
        {
          return new Tag26A((SwiftElement) this, this.SerialNumbers_26A.Length, (SwiftDefinitionElement) MT801.U0019)
          {
            Value = string.Empty
          };
        }

        public void RemoveSerialNumbers_26A(Tag26A tag)
        {
          this.RemoveTag(tag.GetTag());
        }
      }
    }
  }
}
